/**
  ****************************(C) COPYRIGHT 2022 jk****************************
  * @file       gimbal_task.c/h
  * @brief      完成云台控制任务：
				yaw采用了舵机控制，主要实现三个位置方向：前视角，后视角，辅助视角
				pitch采用了2006电机。实现在机械限位上的范围
  * @note
  * @history
  *  Version    Date            Author          Modification
  *  V1.0.0     Dec-26-2018     RM              1. done
  *  V1.1.0     Nov-11-2019     RM              1. add some annotation
  *
  @verbatim
  ==============================================================================

  ==============================================================================
  @endverbatim
  ****************************(C) COPYRIGHT 2022 jk****************************
  */

#ifndef GIMBAL_TASK_H
#define GIMBAL_TASK_H

#include "main.h"
#include "pid.h"
#include "struct_typedef.h"
#include "CAN_receive.h"
#include "remote_control.h"
#include "user_lib.h"


#define gimbal_task_INIT_TIME    200
//yaw,pitch中值
#define offset_yaw_pwm          1500
#define offset_pitch_pwm        1500
#define servo_max_pwm           2400        //最大2500
#define servo_min_pwm           300         //最小500

#define YAW_left                800       
#define YAW_back                1025        
#define YAW_front               365    

//控制系数
#define PITCH_MOUSE_SEN   0.00015f

//滤波系数
#define gimbal_yaw_NUM    0.1666666667f
#define gimbal_pitch_NUM  0.0666666667f
#define engineering_CONTROL_TIME  0.002f


typedef enum
{
	yaw_front = 0,
	yaw_Left,
	yaw_back

}gimbal_state_e;

typedef enum 
{
	gimbal_ZERO_FORCE,
	gimbal_CONTROL

}gimbal_mode_e;


typedef struct 
{
	const RC_ctrl_t* gimbal_rc;
	const can_receive_t* can_rc_chassis;
	gimbal_state_e gimbal_state;
	gimbal_state_e last_gimbal_state;
	gimbal_mode_e gimbal_mode;
	gimbal_mode_e last_gimbal_mode;

	first_order_filter_type_t gimbal_cmd_slow_set_pitch;
	first_order_filter_type_t gimbal_cmd_slow_set_yaw;

	fp32 yaw_set_pwm;
	fp32 pitch_set_pwm;

}gimbal_move_t;







  /**
	* @brief          云台任务
	* @param[in]      pvParameters: ?
	* @retval         none
	*/
extern void gimbal_task(void const* pvParameters);

#endif 



